package com.beilang.hotline.user.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.beilang.base.core.model.BaseModel;
import com.beilang.base.util.StringUtil;
import com.beilang.hotline.login.UserAccessTO;

import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;

@Entity
@Table(name = "ht_user")
public class UserModel extends BaseModel {

    private static final long serialVersionUID = -5342781097710552004L;

    @Id
    @Column(name = "user_id")
    private String userId;

    @Transient
    private String userIdKey;

    @Column(name = "user_name")
    private String userName;

    @Column(name = "user_password")
    private String userPassword;

    @Transient
    private String confirmPassword;

    @Transient
    private String userNewPassword;

    @Column(name = "role")
    private String userRole;

    @Transient
    private String userRoleDesc;

    @Column(name = "pcname")
    private String pcName;

    @Column(name = "channelno")
    private String channelNo;

    @Column(name = "email")
    private String emailAddress;

    @Column(name = "telephone")
    private String telephone;

    @Column(name = "access_function")
    private String accessFunction;

     @Column(name = "company_type")
    private String companyType;
    
    @Column(name = "dept_id")
    private String deptId;

    @Transient
    private String deptName;

    @Transient
	private boolean handlerInd;

    @Column(name = "handler_ind")
    private String handlerIndStr;

   @Transient
    private String handlerIndDesc;

    @Column(name = "delete_ind")
    private String deleteInd = "N";

    @Column(name = "popup_ind")
    private String popupInd = "N";

    @Column(name = "record_mode")
    private String recordMode;

    @Transient
    private String recordModeDesc;    

   @Transient
    private String popupIndDesc;

    @Transient
    private List accessSystemList;

     @Transient
    private List accessCompanyList;

    @Transient
    private UserAccessTO userAccessTO;

    public UserAccessTO getUserAccessTO() {
        return userAccessTO;
    }

    public void setUserAccessTO(UserAccessTO userAccessTO) {
        this.userAccessTO = userAccessTO;
    }


    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserRole() {
        return userRole;
    }

    public void setUserRole(String userRole) {
        this.userRole = userRole;
    }

    public String getPcName() {
        return pcName;
    }

    public void setPcName(String pcName) {
        this.pcName = pcName;
    }

    public String getChannelNo() {
        return channelNo;
    }

    public void setChannelNo(String channelNo) {
        this.channelNo = channelNo;
    }

    public String getUserPassword() {
        return userPassword;
    }

    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword;
    }

    public String getConfirmPassword() {
        return confirmPassword;
    }

    public void setConfirmPassword(String confirmPassword) {
        this.confirmPassword = confirmPassword;
    }

    public String getEmailAddress() {
        return emailAddress;
    }

    public void setEmailAddress(String emailAddress) {
        this.emailAddress = emailAddress;
    }

    public String getAccessFunction() {
        return accessFunction;
    }

    public void setAccessFunction(String accessFunction) {
        this.accessFunction = accessFunction;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getUserRoleDesc() {
        return userRoleDesc;
    }

    public void setUserRoleDesc(String userRoleDesc) {
        this.userRoleDesc = userRoleDesc;
    }

    public List getAccessSystemList() {
        if (StringUtil.isNullOrBlank(accessFunction)) return new ArrayList();
        return Arrays.asList(StringUtil.split(accessFunction, "\\|"));
    }

    public void setAccessSystemList(List accessSystemList) {
        this.accessSystemList = accessSystemList;
    }

    public List getAccessCompanyList() {
         if (StringUtil.isNullOrBlank(companyType)) return new ArrayList();
        return Arrays.asList(StringUtil.split(companyType, "\\|"));
    }

    public void setAccessCompanyList(List accessCompanyList) {
        this.accessCompanyList = accessCompanyList;
    }

    public String getUserNewPassword() {
        return userNewPassword;
    }

    public void setUserNewPassword(String userNewPassword) {
        this.userNewPassword = userNewPassword;
    }

    public String getUserIdKey() {
        return userId;
    }

    public void setUserIdKey(String userIdKey) {
        this.userIdKey = userIdKey;
    }

    public String getDeleteInd() {
        return deleteInd;
    }

    public void setDeleteInd(String deleteInd) {
        this.deleteInd = deleteInd;
    }

    public String getDeptId() {
        return deptId;
    }

    public void setDeptId(String deptId) {
        this.deptId = deptId;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public String getPopupInd() {
        return popupInd;
    }

    public void setPopupInd(String popupInd) {
        this.popupInd = popupInd;
    }

    public String getPopupIndDesc() {
        return popupIndDesc;
    }

    public void setPopupIndDesc(String popupIndDesc) {
        this.popupIndDesc = popupIndDesc;
    }

    public String getHandlerIndDesc() {
        return handlerIndDesc;
    }

    public void setHandlerIndDesc(String handlerIndDesc) {
        this.handlerIndDesc = handlerIndDesc;
    }

    public boolean isHandlerInd() {
        return handlerInd;
    }

    public void setHandlerInd(boolean handlerInd) {
        this.handlerInd = handlerInd;
        if(handlerInd){
            this.handlerIndStr="Y";
        }else{
            this.handlerIndStr="N";            
        }
    }

    public String getHandlerIndStr() {
        return handlerIndStr;
    }

    public void setHandlerIndStr(String handlerIndStr) {
        this.handlerIndStr = handlerIndStr;
        handlerInd = "Y".equalsIgnoreCase(handlerIndStr);
    }


    public String getCompanyType() {
        return companyType;
    }

    public void setCompanyType(String companyType) {
        this.companyType = companyType;
    }

    public String getRecordMode() {
        return recordMode;
    }

    public void setRecordMode(String recordMode) {
        this.recordMode = recordMode;
    }

    public String getRecordModeDesc() {
        return recordModeDesc==null?"":recordModeDesc;
    }

    public void setRecordModeDesc(String recordModeDesc) {
        this.recordModeDesc = recordModeDesc;
    }
}